<?php
include_once 'kahlua.ini';
include_once 'classes/db.php';
include_once 'classes/handlers/comentariosHandler.php';

$commentsH = new comentariosHandler();

$notaid = $_POST["notaid"];
$user = htmlentities($_POST["user"], ENT_COMPAT, "UTF-8");
$email = htmlentities($_POST["email"], ENT_COMPAT, "UTF-8");
$comment = htmlentities($_POST["comment"], ENT_COMPAT, "UTF-8");
$ipAddress = $_SERVER["REMOTE_ADDR"];
$fechaCreado = date("Y-m-d h:i:s");

$commentsH->insertComentario($notaid, $user, $email, $comment, $ipAddress, $fechaCreado, 'A');

$comments = $commentsH->getComentariosPorNotaId($notaid);

foreach($comments as $c){
    echo "<article class='media'>
    <div class='media-body span10'>
        <a href='#'>
            <h4 class='media-heading'>".$c->getUser()."</h4>
        </a>
        <div class='media'>
            <div>
                <p>
                    ".$c->getComentario()."
                </p>
            </div>
            <ul>
                <li>
                    <span title='Comment Time'>
                        <i class='bo-icon-time'>
                        </i>
                        ".date("d m Y H:i", strtotime($c->getFechaCreado()))."
                    </span>
                </li>
            </ul>
        </div>
    </div>
</article>";
}

